﻿using Microsoft.AspNetCore.Mvc;
using WMS.FC.Application.System.Interface;
using WMS.FC.Domain.DataTransferObject.System;
using WMS.FC.Domain.DomainObject.System;
using WMS.FC.Infrastructure.Filter;

namespace WMS.FC.WebApi.Controllers
{
    /// <summary>
    /// 系统控制器
    /// </summary>
    public class SystemController : BaseConroller
    {
        /// <summary>
        /// 系统服务
        /// </summary>
        protected readonly ISystemService systemService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="systemService"></param>
        public SystemController(ISystemService systemService)
        {
            this.systemService = systemService;
        }

        /// <summary>
        /// 获取页面配置
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> GetPageConfig(GetPageConfigDTO dTO)
        {
            var response = await systemService.GetPageConfig(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 获取页面数据
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> GetPageData(GetPageDataDTO dTO)
        {
            var response = await systemService.GetPageData(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 获取数据字典
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> GetDictionary(GetDictionaryDTO dTO)
        {
            var response = await systemService.GetDictionary(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 获取数据字典类型
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> GetDictionaryType(RequestBase dTO)
        {
            var response = await systemService.GetDictionaryType(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 新增数据
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> AddData(HandleButtonDTO dTO)
        {
            var response = await systemService.AddData(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 编辑数据
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> EditData(HandleButtonDTO dTO)
        {
            var response = await systemService.EditData(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 批量编辑
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> BatchEditData(HandleButtonDTO dTO)
        {
            var response = await systemService.BatchEditData(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 查看数据
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> ViewData(HandleButtonDTO dTO)
        {
            var response = await systemService.ViewData(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 导出数据
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> ExportData(HandleButtonDTO dTO)
        {
            var response = await systemService.ExportData(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 操作数据
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> OperateData(HandleButtonDTO dTO)
        {
            var response = await systemService.OperateData(dTO);
            return Ok(response);
        }
    }
}
